import ajax from '@/utils/ajax.js'
import store from 'store'

// 员工登录
export const empLogin = (employee) => {
	return ajax({
		url: '/login',
		data: employee,
		method: 'POST'
	})
}

// 根据id获取员工信息
export const getEmployee = (id) => {
	return ajax({
		url: '/system/user/${id}',
		header: {
			Authorization: store.state.employee
		}
	})
}

// 获取员工详细信息
export const getEmployeeInfo = () => {
	return ajax({
		url: '/getInfo',
		header: {
			Authorization: store.state.employee
		}
	})
}

// 批量发送红包
export const redenvelopes = (data) => {
	return ajax({
		url: '/base/admin/redenvelope/adds',
		header: {
			Authorization: store.state.employee
		},
		data,
		method: 'POST'
	})
}

// 查询订单及明细集合
export const ordersList = (data = {}) => {
	const {
		pageNum = 1,
			pageSize = 999999999
	} = data
	return ajax({
		url: `/base/admin/orders/list?pageNum=${pageNum}&pageSize=${pageSize}`,
		header: {
			Authorization: store.state.employee
		}
	})
}

// 根据id获取订单信息
export const orderInfo = (id) => {
	return ajax({
		url: `/base/admin/orders/${id}`,
		header: {
			Authorization: store.state.employee
		},
	})
}

// 管理员同意退款
export const audit = (data) => {
	return ajax({
		url: `/base/admin/orders/audit`,
		header: {
			Authorization: store.state.employee
		},
		data,
		method: 'POST'
	})
}

// 获取所有会员
export const memberList = () => ajax({
	url: `/base/admin/member/employeeselectlist`,
	header: {
		Authorization: store.state.employee
	}
})

// 根据id获取会员
export const memberInfo = (id) => ajax({
	url: `/base/admin/member/${id}`,
	header: {
		Authorization: store.state.employee
	}
})

// 新增会员
export const addMember = (data) => ajax({
	url: `/base/admin/member`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'POST'
})

// 修改会员
export const updateMember = (data) => ajax({
	url: `/base/admin/member`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'PUT'
})

// 充值
export const recharge = (data) => ajax({
	url: `/base/admin/recharge`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'POST'
})

// 充值支付
export const rechargePay = (data) => ajax({
	url: `/base/admin/recharge/pay`,
	header: {
		Authorization: store.state.employee,
		openid: store.state.userInfo.openid
	},
	data,
	method: 'POST'
})

// 发送单个红包
export const giveRed = (data) => ajax({
	url: `/base/admin/redenvelope`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'POST'
})

// 获取红包记录列表
export const redPacket = () => ajax({
	url: `/base/admin/redenvelope/list`,
	header: {
		Authorization: store.state.employee
	}
})

// 红包退款 
export const redRefund = (id) => ajax({
	url: `/base/admin/redenvelope/refund/${id}`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST'
})

// 获取红包列表
export const getRedPacket = () => ajax({
	url: `/base/admin/redenvelope/getredenvelopelist`,
	header: {
		Authorization: store.state.employee
	}
})

// 获取当前员工的标签
export const tagList = () => ajax({
	url: `/base/admin/label/list`,
	header: {
		Authorization: store.state.employee
	}
})

// 新增标签
export const addTag = (data) => ajax({
	url: `/base/admin/label`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'POST'
})

// 删除标签 
export const deleteTag = (ids) => ajax({
	url: `/base/admin/label/${ids}`,
	header: {
		Authorization: store.state.employee
	},
	method: 'DELETE'
})

// 修改客户标签 
export const updateMemberTag = (data) => ajax({
	url: `/base/admin/member/editLabel`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'POST'
})

// 获取所有员工
export const employeeList = () => ajax({
	url: `/base/admin/statistics/selectEmployeeList`,
	header: {
		Authorization: store.state.employee
	}
})

// 查询优惠券模板列表
export const couponList = () => ajax({
	url: `/base/admin/coupon/list`,
	header: {
		Authorization: store.state.employee
	}
})

// 员工发送优惠券
export const empSendCop = (data) => ajax({
	url: `/base/admin/coupons`,
	header: {
		Authorization: store.state.employee
	},
	data,
	method: 'POST'
})

// 员工发送优惠券
export const cuponsList = (data) => ajax({
	url: `/base/admin/coupons`,
	header: {
		Authorization: store.state.employee
	}
})

// 员工核销卡券
export const verification = (verificationCode) => ajax({
	url: `/base/admin/coupons/Verification?verificationCode=${verificationCode}`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST'
})

// 员工核销提货订单
export const verificationNumber = (number) => ajax({
	url: `/base/admin/orders/ordersVerification?number=${number}`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST'
})

// 获取所有普通用户
export const userList = (data) => ajax({
	url: `/base/admin/user/list?memberStatus=${data.memberStatus}&pageNum=${1}&pageSize=${9999999999999}`,
	header: {
		Authorization: store.state.employee
	}
})

// 查询会员充值记录
export const rechargeList = (userId) => ajax({
	url: `/base/admin/recharge/list?userId=${userId}&pageNum=${1}&pageSize=${9999999999999}`,
	header: {
		Authorization: store.state.employee
	}
})

// 查看用户待提货订单
export const pickList = (userId) => ajax({
	url: `/base/admin/orders/selectPickuplist?userId=${userId}&pageNum=${1}&pageSize=${9999999999999}`,
	header: {
		Authorization: store.state.employee
	}
})


// 员工扫码用户二维码直接添加为会员
export const bindmember = (data) => ajax({
	url: `/base/admin/member/bind`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST',
	data
})

// 小程序用户绑定Crm
export const bindcrm = (data) => ajax({
	url: `/base/admin/user/bindCrm`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST',
	data
})

// 员工发展中客户
export const fmemberlist = (data) => ajax({
	url: `/base/admin/member/f/list`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST',
	data
})

// 员工添加发展中客户
export const addfmember = (data) => ajax({
	url: `/base/admin/member/add`,
	header: {
		Authorization: store.state.employee
	},
	method: 'POST',
	data
})

// 员工添加发展中客户
export const delfmember = (id) => ajax({
	url: `/base/admin/member/del/${id}`,
	header: {
		Authorization: store.state.employee
	},
	method: 'DELETE'
})